package com.blog.service.Impl;

import java.util.List;

import com.blog.BO.PlateBO;
import com.blog.BO.PostBO;
import com.blog.VO.PlateVO;
import com.blog.dao.AllPlateDao;
import com.blog.dao.AllPostDao;
import com.blog.dao.MidTableDao;
import com.blog.dao.MultilistDao;
import com.blog.dao.impl.AllPlateDaoImpl;
import com.blog.dao.impl.AllPostDaoImpl;
import com.blog.dao.impl.MidTableDaoImpl;
import com.blog.dao.impl.MultilistDaoImpl;
import com.blog.entity.Page;
import com.blog.entity.Plate;
import com.blog.entity.Post;
import com.blog.service.PlateService;

public class PlateServiceImpl implements PlateService {
	private AllPlateDao apd=new AllPlateDaoImpl();
	private AllPostDao ap=new AllPostDaoImpl();
	private MidTableDao mtd = new MidTableDaoImpl();
	private MultilistDao mld = new MultilistDaoImpl();
	@Override
	public Page<Plate> selectAllPlate(int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		List<Plate> data= apd.selectPlate(null, pageNum, pageSize);
		int totalRows=apd.selectPlateNum();
		return new Page<Plate>(data, pageNum, pageSize, totalRows);
	}

	@Override
	public List<PlateVO> selectPlateByNum(int num) {
		// TODO Auto-generated method stub
		return mld.selectBestLikePlateByNum(num);
	}

	@Override
	public Page<Post> selectAllPostByPlate(int plateId, int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		PostBO pb= new PostBO();
		pb.setPostPlateId(plateId);
		List<Post> data= ap.selectPost(pb, pageNum, pageSize);
		int num = 20;
		return new Page<Post>(data, pageNum, pageSize,num);
	}

	@Override
	public Plate selectPlate(int plateId) {
		// TODO Auto-generated method stub
		PlateBO pb= new PlateBO();
		pb.setPlateId(plateId);
		List<Plate> data= apd.selectPlate(pb, 1, 1);
		return data.get(0);
	}

}
